//
//  XLViewController.m
//  XLAudioFormatConvertTool
//
//  Created by 10150820867@qq.com on 09/02/2022.
//  Copyright (c) 2022 10150820867@qq.com. All rights reserved.
//

#import "XLViewController.h"
#import <XLAudioFormatConvertTool/XLVoiceConverter.h>
#define CAF_HEADER_NUMBER "caff"
#define WAV_HEADER_NUMBER "RIFF"

@interface XLViewController ()

@end

@implementation XLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
}

- (void)test{
    NSString *wavPath = [[NSBundle mainBundle] pathForResource:@"Voice_250d64339779af" ofType:@"wav"];
    NSString *amrPath = [[NSBundle mainBundle] pathForResource:@"Voice_250d64339779af" ofType:@"amr"];
    NSString *cafPath = [[NSBundle mainBundle] pathForResource:@"2023_02_21_16_54_07_073_recorder" ofType:@"caf"];
    
    NSString *amr = [NSString stringWithFormat:@"%@/Documents/Voice_250d64339779af.amr", NSHomeDirectory()];
    NSString *wav = [NSString stringWithFormat:@"%@/Documents/Voice_250d64339779af.wav", NSHomeDirectory()];
    NSString *mp3 = [NSString stringWithFormat:@"%@/Documents/Voice_250d64339779af.mp3", NSHomeDirectory()];
    NSString *opus = [NSString stringWithFormat:@"%@/Documents/Voice_250d64339779af.ogg", NSHomeDirectory()];
    NSString *silk = [NSString stringWithFormat:@"%@/Documents/Voice_250d64339779af.silk", NSHomeDirectory()];
    
    int ret = [XLVoiceConverter inputFilePath:amrPath
                                inputFileType:AVFileTypeAMR
                               outputFilePath:silk
                               outputFileType:@"silk"
                             outputSampleRate:@"8000"
                             outputSampleBits:@"16"
                               outputChannels:@"1"];
    NSLog(@"");
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
- (IBAction)startEncodeAction:(id)sender {
    [self test];
}

@end
